<template>
  借款人：<input type="text" v-model="searchData.borrower" />
  <button @click="search">搜索</button>
  <Button type="primary">搜索</Button>
  <table>
    <thead>
      <tr>
        <th>id</th>
        <th>借款人</th>
        <th>金额</th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="item in dataSource">
        <td>{{ item.id }}</td>
        <td>{{ item.borrower }}</td>
        <td>{{ item.amount }}</td>
      </tr>
    </tbody>
  </table>
</template>

<script setup>
import { ref } from "vue";
import { getLoansList } from "../../service/loans";
import { useRoute } from "vue-router";
import { Button } from "ant-design-vue";

const route = useRoute();
console.log(route.query.name);
const searchData = ref({ borrower: route.query.name });
const dataSource = ref([]);
const search = async () => {
  const res = await getLoansList(searchData.value);
  dataSource.value = res.data.data.record;
};
search();
</script>

<style></style>
